<style type="text/css">
	.tab_act_content {
		border: 1px solid #ccc;
		border-top: none;
		padding: 10px;
		display: none;
	}
	ul.list_tab_action {
		border-bottom:  1px solid #ccc;
		padding: 0px;
		margin: 0px;
		height: 26px;
	}
	ul.list_tab_action li {
		float: left;
		display: inline;
		padding: 5px 15px;
		font-weight: bold;
		background-color: #eee;
		border: 1px solid #ccc;
		border-bottom: none;
		color: #444;
		-webkit-border-radius: 4px 4px 0px 0px; 
		-moz-border-radius: 4px 4px 0px 0px;
		border-radius: 4px 4px 0px 0px;
		margin-right: 5px;
	}	
	ul.list_tab_action li a{
		color: #444;
		font-weight: bold;
	}
	
	ul.list_tab_action li:hover{
		color: #004F8B;
	}
	ul.list_tab_action li.list_tab_action_active {
		background-color:  #bbb;	
	}	
	.tab_act_content_head {
		height: 30px;
		line-height: 30px;
		color: #777;
		font-size: 13px;
		padding-left: 10px;
		background-color: #eee;
		margin-bottom: 10px;
	}
	.tv_head {
		margin-bottom: 10px;
	}
	.tv_head a {
		text-decoration: underline;
	}
	.tv_head_left {
		float: left;
		width: 250px;
	}
	.tv_head_right {
		float: left;
	}
	.img_std_admin {
	    border: 1px solid #EEEEEE;
	    display: table;
	    height: 152px;
	    padding: 5px 0;
	    width: 208px;
	}
	.img_std_admin div {
	    display: table-cell;
	    vertical-align: middle;
		text-align: center; 
	}
	.sp_indexsub_img {
	    border: medium none;
	    height: auto !important;
	    max-height: 140px;
	    max-width: 190px;
	    min-height: 80px;
	    min-width: 100px;
	    width: auto !important;
	}
</style>

<!-- js format money  -->
<script type="text/javascript" src="<?php echo base_url()?>js/back_end/FormatCurrency.js"></script>

<!-- js validate form  -->
<script type="text/javascript">
$(document).ready(function() {
	 $("#target_2").focus(function() {
		 var target_1 = $("#target_+1").val();
		 $(this).val(target_1); 
	 });
});

$(document).ready(function() {
	$("#add_common").validate();	
	$("#edit_common").validate();	
	$("#add_image").validate();
	$("#add_video").validate();	
});

$.metadata.setType("attr", "validate");
</script>

<script type="text/javascript">
	call('manual');
	call('description');
	call('specifications');
</script>

<script type="text/javascript">
function check_form_editprd() {
	var category_id = document.forms["edit_common"]["category_product_id"].value;

	if (category_id == 0) {
		alert('Bạn cần chọn một danh mục sản phẩm');	
		return false;	
	}
}

function check_form_addprd() {
	var category_id = document.forms["add_common"]["category_product_id"].value;
	
	if (category_id == 0) {
		alert('Bạn cần chọn một danh mục sản phẩm');	
		return false;	
	}
}
</script>

<?php
	 $uri_prd = $this->uri->uri_string();
	 $uri_prd_arr = explode('/',$uri_prd);
	 $uri_active = $uri_prd_arr['3'];
?>

<div class="content_head">
	<?php echo $title; ?>
</div>

<div class="content_ct" style="padding: 10px; padding-top: 20px;">
   <div class="tv_head">
   		<div class="tv_head_left">
	   		<a style="padding-right: 4px;" href="<?php echo base_url(); ?>back_end/product/index" >Liệt kê sản phẩm</a> | 
	   		<a style="padding-left: 4px;"  href="<?php echo base_url(); ?>back_end/product/add/0" >Thêm sản phẩm mới</a>
	   	</div>
	   	<div class="tv_head_right">
	   		<i style="color: red;">		
	   			<?php echo $this->session->flashdata('msview'); ?>
	   		</i>
	   	</div>
	   	<div style="clear: both;"></div>	 
   </div>	
   <ul class="list_tab_action">
   		<li rel="#tb_1" class="<?php if($uri_active == 1) { echo 'list_tab_action_active';} ?>">
   			<a id="tab_one" href="<?php echo base_url(); ?>back_end/product/add/1/<?php if(isset($active_tab)) { echo $active_tab; } ?>">
   				Thông tin chung
   			</a>	
   		</li>
   		<li rel="#tb_2" class="<?php if($uri_active == 2) { echo 'list_tab_action_active';} ?>">
   			<a href="<?php echo base_url(); ?>back_end/product/add/2/<?php if(isset($active_tab)) { echo $active_tab; } ?>">
   				Mô tả sản phẩm
   			</a>	
   		</li>
   		<li rel="#tb_3" class="<?php if($uri_active == 3) { echo 'list_tab_action_active';} ?>">
   			<a href="<?php echo base_url(); ?>back_end/product/add/3/<?php if(isset($active_tab)) { echo $active_tab; } ?>">
   	   			Hình ảnh
   			</a>
   		</li>
   		<li rel="#tb_4" class="<?php if($uri_active == 4) { echo 'list_tab_action_active';} ?>">
   			<a href="<?php echo base_url(); ?>back_end/product/add/4/<?php if(isset($active_tab)) { echo $active_tab; } ?>">
      			Video
   			</a>
   		</li>
   		<li rel="#tb_5" class="<?php if($uri_active == 5) { echo 'list_tab_action_active';} ?>">
   			<a href="<?php echo base_url(); ?>back_end/product/add/5/<?php if(isset($active_tab)) { echo $active_tab; } ?>">
      			Sản phẩm đề cử
   			</a>
   		</li>
   </ul>
   <div style="clear: both; height: 0px;">&nbsp;</div>
   
   <div class="tab_act_content" id="tb_1" style="<?php if($uri_active == 1) { echo 'display:block';}  ?>">
   		<div class="tab_act_content_head">Thông tin chung</div>
   			<?php
   				if(isset($add_common)) {
  			?>
			<form id="edit_common" name="edit_common" onsubmit="return check_form_editprd();" method="POST" action="<?php echo base_url()?>back_end/product/edit_common/<?php echo $add_common['id']; ?>">
				<table class="content_ct_show_add_tbl" width="100%">
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Mã sản phẩm: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input  name="code" class="input_txt_table" value="<?php echo $add_common['code']; ?>" type="text" />
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Tên sản phẩm: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input value="<?php echo $add_common['name']; ?>"  name="name" class="input_txt_table required" type="text" />
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Danh mục sản phẩm: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="category_product_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn danh mục sản phẩm ------</option>
								<?php
									foreach ($category_product as $category_product_key => $category_product_value) { 
								?>
								<option value="<?php echo $category_product_key; ?>" <?php if($category_product_key == $add_common['category_product_id']) { echo 'selected=selected'; } ?>>
									<?php echo $category_product_value; ?>
								</option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Xuất xứ: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="origin_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn nơi xuất xứ ------</option>
								<?php
									foreach ($origin as $origin_arr) { 
								?>
								<option value="<?php echo $origin_arr['id']; ?>" <?php if($origin_arr['id'] == $add_common['origin_id']) { echo 'selected=selected'; } ?>>
									<?php echo $origin_arr['name']; ?>
								</option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Thương hiệu: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="brand_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn thương hiệu ------</option>
								<?php
									foreach ($brand as $brand_arr) { 
								?>
								<option value="<?php echo $brand_arr['id']; ?>"  <?php if($brand_arr['id'] == $add_common['brand_id']) { echo 'selected=selected'; } ?>>
									<?php echo $brand_arr['name']; ?>
								</option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Nhà cung cấp: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="suppliers_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn nhà cung cấp ------</option>
								<?php
									foreach ($suppliers as $suppliers_arr) { 
								?>
								<option value="<?php echo $suppliers_arr['id']; ?>" <?php if($suppliers_arr['id'] == $add_common['suppliers_id']) { echo 'selected=selected'; } ?> >
									<?php echo $suppliers_arr['name']; ?>
								</option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Đơn vị: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="unit_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn đơn vị tính ------</option>
								<?php
									foreach ($unit as $unit_arr) { 
								?>
								<option value="<?php echo $unit_arr['id']; ?>" <?php if($unit_arr['id'] == $add_common['unit_id']) { echo 'selected=selected'; } ?>>
									<?php echo $unit_arr['name']; ?>
								</option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					
					<tr>
						<td colspan="2" valign="baseline" style="border-bottom: 1px dotted #ddd; padding: 0px;">
							&nbsp;
						</td>
					</tr>
					
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Giá niêm yết: </span>
						</td>
						<td width="85%" style="text-align:left; padding-bottom: 10px;">
							<input value="<?php echo $add_common['cost']; ?>"  name="cost" class="input_txt_table required" onkeyup="FormatNumber();" type="text" />
						</td>
					</tr>
					
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Giá bán sỉ: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input value="<?php echo $add_common['wholesale_cost']; ?>"  name="wholesale_cost" class="input_txt_table required" type="text" />
						</td>
					</tr>
					
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Giá mua vào: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input value="<?php echo $add_common['purchase_cost']; ?>"  name="purchase_cost" class="input_txt_table required" type="text" />
						</td>
					</tr>
					
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Số lượng: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input value="<?php echo $add_common['quantity']; ?>"    name="quantity" class="input_txt_table required" type="text" />
						</td>
					</tr>
					
					<tr>
						<td id="lk_tag" style="text-align:left;">
							<span>Kích hoạt: </span>
						</td>
						<td style="text-align:left;">
							<input type="checkbox" value="1" <?php if ($add_common['status'] == 1) { echo 'checked=checked'; } ?> name="status" />
						</td>
					</tr>
					
					<tr>
						<td style="text-align:left;">&nbsp;</td>
						<td style="text-align:left;">
							<input type="submit" name="editForm_common" style="cursor: pointer;" value="Lưu" />
							<input type="reset" style="cursor: pointer;" value="Reset" type="checkbox" />
						</td>
					</tr>
				</table>
			</form>
			<?php
   				} else { 
			?>
			<form id="add_common" name="add_common" method="POST" onsubmit="return check_form_addprd();" action="<?php echo base_url()?>back_end/product/add_common">
				<table class="content_ct_show_add_tbl" width="100%">
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Mã sản phẩm: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input  name="code" class="input_txt_table" type="text" />
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Tên sản phẩm: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input  name="name" class="input_txt_table required" type="text" />
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Danh mục sản phẩm: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="category_product_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn danh mục sản phẩm ------</option>
								<?php
									foreach ($category_product as $category_product_key => $category_product_value) { 
								?>
								<option value="<?php echo $category_product_key; ?>">
									<?php echo $category_product_value; ?>
								</option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Xuất xứ: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="origin_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn nơi xuất xứ ------</option>
								<?php
									foreach ($origin as $origin_arr) { 
								?>
								<option value="<?php echo $origin_arr['id']; ?>"><?php echo $origin_arr['name']; ?></option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Thương hiệu: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="brand_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn thương hiệu ------</option>
								<?php
									foreach ($brand as $brand_arr) { 
								?>
								<option value="<?php echo $brand_arr['id']; ?>"><?php echo $brand_arr['name']; ?></option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Nhà cung cấp: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="suppliers_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn nhà cung cấp ------</option>
								<?php
									foreach ($suppliers as $suppliers_arr) { 
								?>
								<option value="<?php echo $suppliers_arr['id']; ?>"><?php echo $suppliers_arr['name']; ?></option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Đơn vị: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<select name="unit_id" class="content_ct_search_tblselect_2" >
								<option value="0">------ Chọn đơn vị tính ------</option>
								<?php
									foreach ($unit as $unit_arr) { 
								?>
								<option value="<?php echo $unit_arr['id']; ?>"><?php echo $unit_arr['name']; ?></option>
								<?php
									} 
								?>
							</select>
						</td>
					</tr>
					
					<tr>
						<td colspan="2" valign="baseline" style="border-bottom: 1px dotted #ddd; padding: 0px;">
							&nbsp;
						</td>
					</tr>
					
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Giá niêm yết: </span>
						</td>
						<td width="85%" style="text-align:left; padding-bottom: 10px;">
							<input  name="cost" onkeyup="FormatNumber(this);"  class="input_txt_table" type="text" />
						</td>
					</tr>
					
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Giá bán sỉ: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input  name="wholesale_cost"  onkeyup="FormatNumber(this);" class="input_txt_table" type="text" />
						</td>
					</tr>
					
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Giá mua vào: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input  name="purchase_cost"  onkeyup="FormatNumber(this);" class="input_txt_table" type="text" />
						</td>
					</tr>
					
					<tr>
						<td width="15%" style="text-align:left;">
							<span>Số lượng: </span>
						</td>
						<td width="85%" style="text-align:left;">
							<input  name="quantity" class="number input_txt_table" type="text" />
						</td>
					</tr>
					
					<tr>
						<td id="lk_tag" style="text-align:left;">
							<span>Kích hoạt: </span>
						</td>
						<td style="text-align:left;">
							<input type="checkbox" value="1" name="status" />
						</td>
					</tr>
					
					<tr>
						<td style="text-align:left;">&nbsp;</td>
						<td style="text-align:left;">
							<input type="submit" name="addForm_common" style="cursor: pointer;" value="Lưu" />
							<input type="reset" style="cursor: pointer;" value="Reset" type="checkbox" />
						</td>
					</tr>
				</table>
			</form>			
			<?php
   				} 
			?>
   </div>
   
   <div class="tab_act_content" id="tb_2" style="<?php if($uri_active == 2) { echo 'display:block';}  ?>">
   		<div class="tab_act_content_head">Mô tả sản phẩm</div>
   		<?php 
   			if(isset($add_common)) {
   		?>
   		<form id="add_description" method="POST" action="<?php echo base_url()?>back_end/product/add_description/<?php echo $add_common['id']; ?>">
			<table class="content_ct_show_add_tbl" width="100%">
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Chi tiết kỹ thuật: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<textarea id="specifications" name="specifications" style="height: 600px; width:900px;" class="input_area_table"><?php  echo $add_common['specifications']; ?></textarea>
					</td>
				</tr>
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Hướng dẫn sử dụng: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<textarea id="manual" name="manual" style="height: 600px; width:900px;"  class="input_area_table"><?php  echo $add_common['manual']; ?></textarea>
					</td>
				</tr>
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Mô tả: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<textarea id="description" name="description" style="height: 600px; width:900px;" class="input_area_table"><?php  echo $add_common['description']; ?></textarea>
					</td>
				</tr>
				<tr>
					<td width="15%" style="text-align:left;">
						<span>Tag sản phẩm: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<input value="<?php  echo $add_common['tags']; ?>"  name="tags"  class="input_txt_table required" type="text" />
					</td>
				</tr>
				<tr>
					<td style="text-align:left;">&nbsp;</td>
					<td style="text-align:left;">
						<input type="submit" name="addForm_description" style="cursor: pointer;" value="Lưu" />
						<input type="reset" style="cursor: pointer;" value="Reset" type="checkbox" />
					</td>
				</tr>
			</table>
		</form>
		<?php
   			} 
		?>
   </div>
   
   <div class="tab_act_content" id="tb_3" style="<?php if($uri_active == 3) { echo 'display:block';}  ?>">
   		<div class="tab_act_content_head">Ảnh sản phẩm</div>
   		<?php 
   			if(isset($add_common) && empty($add_image_1)) {
   		?>
   		<form id="add_image" method="POST" enctype="multipart/form-data" action="<?php echo base_url()?>back_end/product/add_image/<?php echo $add_common['id']; ?>">
			<table class="content_ct_show_add_tbl" width="100%">
				<tr>
					<td width="10%" valign="top" style="text-align:left;">
						<span>Ảnh đại diện: </span>
					</td>
					<td width="90%" style="text-align:left;">
						<input type="file" value="" name="image" /> 
					</td>
				</tr>
				<tr>
					<td colspan="2" style="border-bottom: 1px dotted #ddd;">&nbsp;</td>
				</tr>
				<tr>
					<td width="10%" valign="top" style="text-align:left;">
						<span>Ảnh 1: </span>
					</td>
					<td width="90%" style="text-align:left;">
						<input type="file" value="" name="image_1" /> 
					</td>
				</tr>
				<tr>
					<td width="10%" valign="top" style="text-align:left;">
						<span>Ảnh 2: </span>
					</td>
					<td width="90%" style="text-align:left;">
						<input type="file" value="" name="image_2" /> 
					</td>
				</tr>
				<tr>
					<td width="10%" valign="top" style="text-align:left;">
						<span>Ảnh 3: </span>
					</td>
					<td width="90%" style="text-align:left;">
						<input type="file" value="" name="image_3" /> 
					</td>
				</tr>
				<tr>
					<td width="10%" valign="top" style="text-align:left;">
						<span>Ảnh 4: </span>
					</td>
					<td width="90%" style="text-align:left;">
						<input type="file" value="" name="image_4" /> 
					</td>
				</tr>
				<tr>
					<td style="text-align:left;">&nbsp;</td>
					<td style="text-align:left;">
						<input type="submit" name="addForm_image" style="cursor: pointer;" value="Lưu" />
						<input type="reset" style="cursor: pointer;" value="Reset" type="checkbox" />
					</td>
				</tr>
			</table>
		</form>
		<?php
   			}  else if (isset($add_common) && !empty($add_image_1)) {
		?>
		<form id="add_image" method="POST" enctype="multipart/form-data" action="<?php echo base_url()?>back_end/product/edit_image/<?php echo $add_common['id']; ?>">
			<table class="content_ct_show_add_tbl" width="100%">
				<tr>
					<td width="10%" valign="top" style="text-align:left;">
						<span>Ảnh đại diện: </span>
					</td>
					<?php 
						if ($add_image_1['image'] !== '') {
					?>
					<td width="90%" style="text-align:left;">
						<div class="img_std_admin">
							<div>
								<img src="<?php echo base_url();?>images/img_product/<?php echo $add_image_1['image']; ?>"  class="sp_indexsub_img">
							</div>	
						</div>
						<input type="file" value="" name="image" /> 
					</td>
					<?php
						} else {
					 ?>
					<td width="90%" style="text-align:left;">
						<input type="file" value="" name="image" /> 
					</td>
					 <?php
						} 
					 ?>
				</tr>
				<tr>
					<td colspan="2" style="border-bottom: 1px dotted #ddd;">&nbsp;</td>
				</tr>
				<?php 
					$i = 0; 
					if (count($add_image_2) > 0) {
						foreach ($add_image_2 as $add_image_2_arr) {
		                	$i++; 
	            ?>
				<tr>
					<td width="10%" valign="top" style="text-align:left;">
						<span>Ảnh <?php echo $i; ?>: </span>
					</td>
					<td width="90%" style="text-align:left;">
						<div class="img_std_admin">
							<div>
								<img src="<?php echo base_url();?>images/img_product/<?php echo $add_image_2_arr['image']; ?>"  class="sp_indexsub_img">
							</div>	
						</div>
						<input type="file" value="" name="image_<?php echo $add_image_2_arr['id']; ?>" /> 
					</td>
				</tr>
				<?php
						}
   					}
   						 
                    $ct = 4 - count($add_image_2);
                    $ct_img = count($add_image_2); 
                 	
                    for ($j = 1; $j <= $ct; $j++) {
				?>
					<tr>
                    	<td width="10%" valign="top" style="text-align:left;">
                    		<span>Ảnh <?php echo $j+$ct_img ;?>: </span>
                    	</td>
                    	<td width="90%" style="text-align:left;">
                    		<input type="file"  value="" name="image_<?php echo $j+$ct_img ;?>" />
                    	</td>
                  	</tr>
				<?php 
					}
				?>
				<tr>
					<td style="text-align:left;">&nbsp;</td>
					<td style="text-align:left;">
						<input type="submit" name="addForm_image" style="cursor: pointer;" value="Lưu" />
						<input type="reset" style="cursor: pointer;" value="Reset" type="checkbox" />
					</td>
				</tr>
			</table>
		</form>
		<?php
   			} 
		?>
   </div>
   
   <div class="tab_act_content" id="tb_4" style="<?php if($uri_active == 4) { echo 'display:block';}  ?>">
   		<div class="tab_act_content_head">Video sản phẩm</div>
   		<?php 
   			if(isset($add_common) && !isset($add_video)) {
   		?>
   		<form id="add_video" method="POST" enctype="multipart/form-data" action="<?php echo base_url()?>back_end/product/add_video/<?php echo $add_common['id']; ?>">
			<table class="content_ct_show_add_tbl" width="100%">
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Tên video: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<input  name="name" class="input_txt_table required" type="text" />
					</td>
				</tr>
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Đường dẫn: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<input  name="link" class="input_txt_table required url" type="text" />
					</td>
				</tr>
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Mô tả: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<textarea name="description"  class="input_area_table"></textarea>
					</td>
				</tr>
				<tr>
					<td id="lk_tag" style="text-align:left;">
						<span>Kích hoạt: </span>
					</td>
					<td style="text-align:left;">
						<input type="checkbox" value="1" name="status" />
					</td>
				</tr>
				<tr>
					<td style="text-align:left;">&nbsp;</td>
					<td style="text-align:left;">
						<input type="submit" name="addForm_video" style="cursor: pointer;" value="Lưu" />
						<input type="reset" style="cursor: pointer;" value="Reset" type="checkbox" />
					</td>
				</tr>				
			</table>
		</form>
		<?php
   			}  else if (isset($add_common) && isset($add_video)) {
		?>
		<form id="add_video" method="POST" enctype="multipart/form-data" action="<?php echo base_url()?>back_end/product/edit_video/<?php echo $add_common['id']; ?>">
			<table class="content_ct_show_add_tbl" width="100%">
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Tên video: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<input value="<?php echo $add_video['name']; ?>"  name="name" class="input_txt_table required" type="text" />
					</td>
				</tr>
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Đường dẫn: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<input value="<?php echo $add_video['link']; ?>"  name="link" class="input_txt_table required url" type="text" />
						<?php
							$video_path    = explode("watch?v=", $add_video['link']);

							if (count($video_path) > 1) {
     							$video_path    = $video_path[0]."v/".$video_path[1];
							} else {
								$video_path    = "";
							} 
						?>
						<?php if(!empty($video_path)) { ?>
						<div style="margin-top: 10px;">
							<object width="188" height="150" name="player" id="player">
								<param name="movie">
								<param value="true" name="allowFullScreen">
								<param value="always" name="allowscriptaccess">
								<embed width="320" height="230" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" name="player2" id="player2" src="<?php echo $video_path; ?>" wmode="opaque">
							</object>
						</div>
						<?php } else { ?>
						<div style="margin-top: 10px;">
							<i style="color: red;">Video không hiển thị được</i>
						</div>		
						<?php }?>
					</td>
				</tr>
				<tr>
					<td width="15%" valign="top" style="text-align:left;">
						<span>Mô tả: </span>
					</td>
					<td width="85%" style="text-align:left;">
						<textarea name="description"  class="input_area_table"><?php  echo $add_video['description']; ?></textarea>
					</td>
				</tr>
				<tr>
					<td id="lk_tag" style="text-align:left;">
						<span>Kích hoạt: </span>
					</td>
					<td style="text-align:left;">
						<input type="checkbox" value="1" <?php if ($add_video['status'] == 1) { echo 'checked=checked'; } ?> name="status" />
					</td>
				</tr>
				<tr>
					<td style="text-align:left;">&nbsp;</td>
					<td style="text-align:left;">
						<input type="submit" name="addForm_video" style="cursor: pointer;" value="Lưu" />
						<input type="reset" style="cursor: pointer;" value="Reset" type="checkbox" />
					</td>
				</tr>
			</table>	
		</form>
		<?php
   			} 
		?>
   </div>
</div>

<!-- js validate form  -->
<script type="text/javascript">
	<?php
		if(empty($add_common) && $_SESSION['value_id'] == 2 || empty($add_common) && $_SESSION['value_id'] == 3 || empty($add_common) && $_SESSION['value_id'] == 4 || empty($add_common) && $_SESSION['value_id'] == 5){
			echo "alert('Bạn chưa nhập thông tin chung cho sản phẩm')";		
		} 
	?>
</script>